{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "322d532a-67e7-4f06-8d52-f8e0910e759a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting pdfplumber (from -r requirements.txt (line 1))\n",
      "  Downloading pdfplumber-0.10.3-py3-none-any.whl.metadata (38 kB)\n",
      "Collecting simplejson (from -r requirements.txt (line 2))\n",
      "  Downloading simplejson-3.19.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.1 kB)\n",
      "Requirement already satisfied: requests in /opt/conda/lib/python3.11/site-packages (from -r requirements.txt (line 3)) (2.31.0)\n",
      "Requirement already satisfied: PyYAML in /opt/conda/lib/python3.11/site-packages (from -r requirements.txt (line 4)) (6.0.1)\n",
      "Collecting pillow (from -r requirements.txt (line 5))\n",
      "  Downloading Pillow-10.1.0-cp311-cp311-manylinux_2_28_x86_64.whl.metadata (9.5 kB)\n",
      "Collecting reportlab (from -r requirements.txt (line 6))\n",
      "  Downloading reportlab-4.0.8-py3-none-any.whl.metadata (1.4 kB)\n",
      "Collecting pandas (from -r requirements.txt (line 7))\n",
      "  Downloading pandas-2.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (18 kB)\n",
      "Collecting loguru (from -r requirements.txt (line 8))\n",
      "  Downloading loguru-0.7.2-py3-none-any.whl.metadata (23 kB)\n",
      "Collecting openai (from -r requirements.txt (line 9))\n",
      "  Downloading openai-1.6.1-py3-none-any.whl.metadata (17 kB)\n",
      "Collecting pdfminer.six==20221105 (from pdfplumber->-r requirements.txt (line 1))\n",
      "  Downloading pdfminer.six-20221105-py3-none-any.whl (5.6 MB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.6/5.6 MB\u001b[0m \u001b[31m18.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
      "\u001b[?25hCollecting pypdfium2>=4.18.0 (from pdfplumber->-r requirements.txt (line 1))\n",
      "  Downloading pypdfium2-4.25.0-py3-none-manylinux_2_17_x86_64.whl.metadata (47 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m47.8/47.8 kB\u001b[0m \u001b[31m3.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: charset-normalizer>=2.0.0 in /opt/conda/lib/python3.11/site-packages (from pdfminer.six==20221105->pdfplumber->-r requirements.txt (line 1)) (3.3.0)\n",
      "Requirement already satisfied: cryptography>=36.0.0 in /opt/conda/lib/python3.11/site-packages (from pdfminer.six==20221105->pdfplumber->-r requirements.txt (line 1)) (41.0.4)\n",
      "Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.11/site-packages (from requests->-r requirements.txt (line 3)) (3.4)\n",
      "Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.11/site-packages (from requests->-r requirements.txt (line 3)) (2.0.7)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.11/site-packages (from requests->-r requirements.txt (line 3)) (2023.7.22)\n",
      "Collecting chardet (from reportlab->-r requirements.txt (line 6))\n",
      "  Downloading chardet-5.2.0-py3-none-any.whl.metadata (3.4 kB)\n",
      "Collecting numpy<2,>=1.23.2 (from pandas->-r requirements.txt (line 7))\n",
      "  Downloading numpy-1.26.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m61.2/61.2 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: python-dateutil>=2.8.2 in /opt/conda/lib/python3.11/site-packages (from pandas->-r requirements.txt (line 7)) (2.8.2)\n",
      "Requirement already satisfied: pytz>=2020.1 in /opt/conda/lib/python3.11/site-packages (from pandas->-r requirements.txt (line 7)) (2023.3.post1)\n",
      "Collecting tzdata>=2022.1 (from pandas->-r requirements.txt (line 7))\n",
      "  Downloading tzdata-2023.4-py2.py3-none-any.whl.metadata (1.4 kB)\n",
      "Requirement already satisfied: anyio<5,>=3.5.0 in /opt/conda/lib/python3.11/site-packages (from openai->-r requirements.txt (line 9)) (4.0.0)\n",
      "Collecting distro<2,>=1.7.0 (from openai->-r requirements.txt (line 9))\n",
      "  Downloading distro-1.9.0-py3-none-any.whl.metadata (6.8 kB)\n",
      "Collecting httpx<1,>=0.23.0 (from openai->-r requirements.txt (line 9))\n",
      "  Downloading httpx-0.26.0-py3-none-any.whl.metadata (7.6 kB)\n",
      "Collecting pydantic<3,>=1.9.0 (from openai->-r requirements.txt (line 9))\n",
      "  Downloading pydantic-2.5.3-py3-none-any.whl.metadata (65 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m65.6/65.6 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: sniffio in /opt/conda/lib/python3.11/site-packages (from openai->-r requirements.txt (line 9)) (1.3.0)\n",
      "Requirement already satisfied: tqdm>4 in /opt/conda/lib/python3.11/site-packages (from openai->-r requirements.txt (line 9)) (4.66.1)\n",
      "Requirement already satisfied: typing-extensions<5,>=4.7 in /opt/conda/lib/python3.11/site-packages (from openai->-r requirements.txt (line 9)) (4.8.0)\n",
      "Collecting httpcore==1.* (from httpx<1,>=0.23.0->openai->-r requirements.txt (line 9))\n",
      "  Downloading httpcore-1.0.2-py3-none-any.whl.metadata (20 kB)\n",
      "Collecting h11<0.15,>=0.13 (from httpcore==1.*->httpx<1,>=0.23.0->openai->-r requirements.txt (line 9))\n",
      "  Downloading h11-0.14.0-py3-none-any.whl (58 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m58.3/58.3 kB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hCollecting annotated-types>=0.4.0 (from pydantic<3,>=1.9.0->openai->-r requirements.txt (line 9))\n",
      "  Downloading annotated_types-0.6.0-py3-none-any.whl.metadata (12 kB)\n",
      "Collecting pydantic-core==2.14.6 (from pydantic<3,>=1.9.0->openai->-r requirements.txt (line 9))\n",
      "  Downloading pydantic_core-2.14.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.5 kB)\n",
      "Requirement already satisfied: six>=1.5 in /opt/conda/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas->-r requirements.txt (line 7)) (1.16.0)\n",
      "Requirement already satisfied: cffi>=1.12 in /opt/conda/lib/python3.11/site-packages (from cryptography>=36.0.0->pdfminer.six==20221105->pdfplumber->-r requirements.txt (line 1)) (1.16.0)\n",
      "Requirement already satisfied: pycparser in /opt/conda/lib/python3.11/site-packages (from cffi>=1.12->cryptography>=36.0.0->pdfminer.six==20221105->pdfplumber->-r requirements.txt (line 1)) (2.21)\n",
      "Downloading pdfplumber-0.10.3-py3-none-any.whl (48 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.0/49.0 kB\u001b[0m \u001b[31m2.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading simplejson-3.19.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (144 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m144.7/144.7 kB\u001b[0m \u001b[31m7.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading Pillow-10.1.0-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.6/3.6 MB\u001b[0m \u001b[31m18.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
      "\u001b[?25hDownloading reportlab-4.0.8-py3-none-any.whl (1.9 MB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.9/1.9 MB\u001b[0m \u001b[31m12.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
      "\u001b[?25hDownloading pandas-2.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.2 MB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m12.2/12.2 MB\u001b[0m \u001b[31m19.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
      "\u001b[?25hDownloading loguru-0.7.2-py3-none-any.whl (62 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m62.5/62.5 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading openai-1.6.1-py3-none-any.whl (225 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m225.4/225.4 kB\u001b[0m \u001b[31m13.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading distro-1.9.0-py3-none-any.whl (20 kB)\n",
      "Downloading httpx-0.26.0-py3-none-any.whl (75 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m75.9/75.9 kB\u001b[0m \u001b[31m5.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading httpcore-1.0.2-py3-none-any.whl (76 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m76.9/76.9 kB\u001b[0m \u001b[31m3.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading numpy-1.26.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m18.2/18.2 MB\u001b[0m \u001b[31m22.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
      "\u001b[?25hDownloading pydantic-2.5.3-py3-none-any.whl (381 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m381.9/381.9 kB\u001b[0m \u001b[31m11.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading pydantic_core-2.14.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.1/2.1 MB\u001b[0m \u001b[31m17.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",
      "\u001b[?25hDownloading pypdfium2-4.25.0-py3-none-manylinux_2_17_x86_64.whl (3.0 MB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.0/3.0 MB\u001b[0m \u001b[31m23.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
      "\u001b[?25hDownloading tzdata-2023.4-py2.py3-none-any.whl (346 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m346.6/346.6 kB\u001b[0m \u001b[31m17.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading chardet-5.2.0-py3-none-any.whl (199 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m199.4/199.4 kB\u001b[0m \u001b[31m11.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading annotated_types-0.6.0-py3-none-any.whl (12 kB)\n",
      "Installing collected packages: tzdata, simplejson, pypdfium2, pydantic-core, pillow, numpy, loguru, h11, distro, chardet, annotated-types, reportlab, pydantic, pandas, httpcore, pdfminer.six, httpx, pdfplumber, openai\n",
      "Successfully installed annotated-types-0.6.0 chardet-5.2.0 distro-1.9.0 h11-0.14.0 httpcore-1.0.2 httpx-0.26.0 loguru-0.7.2 numpy-1.26.2 openai-1.6.1 pandas-2.1.4 pdfminer.six-20221105 pdfplumber-0.10.3 pillow-10.1.0 pydantic-2.5.3 pydantic-core-2.14.6 pypdfium2-4.25.0 reportlab-4.0.8 simplejson-3.19.2 tzdata-2023.4\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "pip install -r requirements.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "6030cdb6-102c-4fb6-a153-701b54556b4f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[32m2023-12-31 09:21:38.854\u001b[0m | \u001b[34m\u001b[1mDEBUG   \u001b[0m | \u001b[36mtranslator.pdf_parser\u001b[0m:\u001b[36mparse_pdf\u001b[0m:\u001b[36m46\u001b[0m - \u001b[34m\u001b[1m[raw_text]\n",
      " Test Data\n",
      "This dataset contains two test samples provided by ChatGPT, an AI language model by OpenAI.\n",
      "These samples include a markdown table and an English text passage, which can be used to test an\n",
      "English-to-Chinese translation software supporting both text and table formats.\n",
      "Text testing\n",
      "The quick brown fox jumps over the lazy dog. This pangram contains every letter of the English\n",
      "alphabet at least once. Pangrams are often used to test fonts, keyboards, and other text-related\n",
      "tools. In addition to English, there are pangrams in many other languages. Some pangrams are more\n",
      "difficult to construct due to the unique characteristics of the language.\n",
      "Table Testing\u001b[0m\n",
      "\u001b[32m2023-12-31 09:21:38.870\u001b[0m | \u001b[34m\u001b[1mDEBUG   \u001b[0m | \u001b[36mtranslator.pdf_parser\u001b[0m:\u001b[36mparse_pdf\u001b[0m:\u001b[36m54\u001b[0m - \u001b[34m\u001b[1m[table]\n",
      "[Fruit, Color, Price (USD)] [Apple, Red, 1.20] [Banana, Yellow, 0.50] [Orange, Orange, 0.80] [Strawberry, Red, 2.50] [Blueberry, Blue, 3.00] [Kiwi, Green, 1.00] [Mango, Orange, 1.50] [Grape, Purple, 2.00]\u001b[0m\n",
      "\u001b[32m2023-12-31 09:21:38.954\u001b[0m | \u001b[34m\u001b[1mDEBUG   \u001b[0m | \u001b[36mtranslator.pdf_translator\u001b[0m:\u001b[36mtranslate_pdf\u001b[0m:\u001b[36m19\u001b[0m - \u001b[34m\u001b[1m翻译为中文：Test Data\n",
      "This dataset contains two test samples provided by ChatGPT, an AI language model by OpenAI.\n",
      "These samples include a markdown table and an English text passage, which can be used to test an\n",
      "English-to-Chinese translation software supporting both text and table formats.\n",
      "Text testing\n",
      "The quick brown fox jumps over the lazy dog. This pangram contains every letter of the English\n",
      "alphabet at least once. Pangrams are often used to test fonts, keyboards, and other text-related\n",
      "tools. In addition to English, there are pangrams in many other languages. Some pangrams are more\n",
      "difficult to construct due to the unique characteristics of the language.\n",
      "Table Testing\u001b[0m\n",
      "\u001b[32m2023-12-31 09:21:49.333\u001b[0m | \u001b[1mINFO    \u001b[0m | \u001b[36mtranslator.pdf_translator\u001b[0m:\u001b[36mtranslate_pdf\u001b[0m:\u001b[36m21\u001b[0m - \u001b[1m测试数据\n",
      "这个数据集包含了由OpenAI的AI语言模型ChatGPT提供的两个测试样本。\n",
      "这些样本包括一个Markdown表格和一个英文文本段落，可用于测试支持文本和表格格式的英译中翻译软件。\n",
      "文本测试\n",
      "快速的棕色狐狸跳过了懒狗。 这是一个包含了英语字母表中至少一次的句子。 为了测试字体、键盘和其他与文本相关的工具，常常会使用这样的句子。 除了英语之外，其他许多语言也有这样的句子。 由于语言的独特特点，有些句子更难以构建。\n",
      "表格测试\u001b[0m\n",
      "\u001b[32m2023-12-31 09:21:49.345\u001b[0m | \u001b[34m\u001b[1mDEBUG   \u001b[0m | \u001b[36mtranslator.pdf_translator\u001b[0m:\u001b[36mtranslate_pdf\u001b[0m:\u001b[36m19\u001b[0m - \u001b[34m\u001b[1m翻译为中文，保持间距（空格，分隔符），以表格形式返回：\n",
      "[Fruit, Color, Price (USD)] [Apple, Red, 1.20] [Banana, Yellow, 0.50] [Orange, Orange, 0.80] [Strawberry, Red, 2.50] [Blueberry, Blue, 3.00] [Kiwi, Green, 1.00] [Mango, Orange, 1.50] [Grape, Purple, 2.00]\u001b[0m\n",
      "\u001b[32m2023-12-31 09:21:55.132\u001b[0m | \u001b[1mINFO    \u001b[0m | \u001b[36mtranslator.pdf_translator\u001b[0m:\u001b[36mtranslate_pdf\u001b[0m:\u001b[36m21\u001b[0m - \u001b[1m水果    颜色     价格（美元）\n",
      "Apple    红色     1.20\n",
      "Banana   黄色     0.50\n",
      "Orange   橙色     0.80\n",
      "Strawberry  红色  2.50\n",
      "Blueberry   蓝色  3.00\n",
      "Kiwi        绿色  1.00\n",
      "Mango       橙色  1.50\n",
      "Grape       紫色  2.00\u001b[0m\n",
      "\u001b[32m2023-12-31 09:21:55.135\u001b[0m | \u001b[34m\u001b[1mDEBUG   \u001b[0m | \u001b[36mbook.content\u001b[0m:\u001b[36mset_translation\u001b[0m:\u001b[36m49\u001b[0m - \u001b[34m\u001b[1m水果    颜色     价格（美元）\n",
      "Apple    红色     1.20\n",
      "Banana   黄色     0.50\n",
      "Orange   橙色     0.80\n",
      "Strawberry  红色  2.50\n",
      "Blueberry   蓝色  3.00\n",
      "Kiwi        绿色  1.00\n",
      "Mango       橙色  1.50\n",
      "Grape       紫色  2.00\u001b[0m\n",
      "\u001b[32m2023-12-31 09:21:55.137\u001b[0m | \u001b[34m\u001b[1mDEBUG   \u001b[0m | \u001b[36mbook.content\u001b[0m:\u001b[36mset_translation\u001b[0m:\u001b[36m52\u001b[0m - \u001b[34m\u001b[1m[['水果', '颜色', '价格（美元）'], ['Apple', '红色', '1.20'], ['Banana', '黄色', '0.50'], ['Orange', '橙色', '0.80'], ['Strawberry', '红色', '2.50'], ['Blueberry', '蓝色', '3.00'], ['Kiwi', '绿色', '1.00'], ['Mango', '橙色', '1.50'], ['Grape', '紫色', '2.00']]\u001b[0m\n",
      "\u001b[32m2023-12-31 09:21:55.141\u001b[0m | \u001b[34m\u001b[1mDEBUG   \u001b[0m | \u001b[36mbook.content\u001b[0m:\u001b[36mset_translation\u001b[0m:\u001b[36m55\u001b[0m - \u001b[34m\u001b[1m           水果  颜色 价格（美元）\n",
      "0       Apple  红色   1.20\n",
      "1      Banana  黄色   0.50\n",
      "2      Orange  橙色   0.80\n",
      "3  Strawberry  红色   2.50\n",
      "4   Blueberry  蓝色   3.00\n",
      "5        Kiwi  绿色   1.00\n",
      "6       Mango  橙色   1.50\n",
      "7       Grape  紫色   2.00\u001b[0m\n",
      "\u001b[32m2023-12-31 09:21:55.158\u001b[0m | \u001b[1mINFO    \u001b[0m | \u001b[36mtranslator.writer\u001b[0m:\u001b[36m_save_translated_book_markdown\u001b[0m:\u001b[36m83\u001b[0m - \u001b[1mpdf_file_path: tests/test.pdf\u001b[0m\n",
      "\u001b[32m2023-12-31 09:21:55.159\u001b[0m | \u001b[1mINFO    \u001b[0m | \u001b[36mtranslator.writer\u001b[0m:\u001b[36m_save_translated_book_markdown\u001b[0m:\u001b[36m84\u001b[0m - \u001b[1m开始翻译: tests/test_translated.md\u001b[0m\n",
      "\u001b[32m2023-12-31 09:21:55.161\u001b[0m | \u001b[1mINFO    \u001b[0m | \u001b[36mtranslator.writer\u001b[0m:\u001b[36m_save_translated_book_markdown\u001b[0m:\u001b[36m108\u001b[0m - \u001b[1m翻译完成: tests/test_translated.md\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!python ai_translator/main.py --model_type OpenAIModel --openai_api_key $OPENAI_API_KEY --file_format markdown --book tests/test.pdf --openai_model gpt-3.5-turbo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "ff71be70-5848-42c6-a5e6-1d87c6023c89",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "测试数据\n",
      "这个数据集包含了由OpenAI的AI语言模型ChatGPT提供的两个测试样本。\n",
      "这些样本包括一个Markdown表格和一个英文文本段落，可用于测试支持文本和表格格式的英译中翻译软件。\n",
      "文本测试\n",
      "快速的棕色狐狸跳过了懒狗。 这是一个包含了英语字母表中至少一次的句子。 为了测试字体、键盘和其他与文本相关的工具，常常会使用这样的句子。 除了英语之外，其他许多语言也有这样的句子。 由于语言的独特特点，有些句子更难以构建。\n",
      "表格测试\n",
      "\n",
      "| 水果 | 颜色 | 价格（美元） |\n",
      "| --- | --- | --- |\n",
      "| Apple | 红色 | 1.20 |\n",
      "| Banana | 黄色 | 0.50 |\n",
      "| Orange | 橙色 | 0.80 |\n",
      "| Strawberry | 红色 | 2.50 |\n",
      "| Blueberry | 蓝色 | 3.00 |\n",
      "| Kiwi | 绿色 | 1.00 |\n",
      "| Mango | 橙色 | 1.50 |\n",
      "| Grape | 紫色 | 2.00 |\n",
      "\n",
      "---\n",
      "\n"
     ]
    }
   ],
   "source": [
    "!cat tests/test_translated.md"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "646254ff-7947-4395-be2f-25825631e532",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting Flask\n",
      "  Downloading flask-3.0.0-py3-none-any.whl.metadata (3.6 kB)\n",
      "Collecting Werkzeug>=3.0.0 (from Flask)\n",
      "  Downloading werkzeug-3.0.1-py3-none-any.whl.metadata (4.1 kB)\n",
      "Requirement already satisfied: Jinja2>=3.1.2 in /opt/conda/lib/python3.11/site-packages (from Flask) (3.1.2)\n",
      "Collecting itsdangerous>=2.1.2 (from Flask)\n",
      "  Downloading itsdangerous-2.1.2-py3-none-any.whl (15 kB)\n",
      "Collecting click>=8.1.3 (from Flask)\n",
      "  Downloading click-8.1.7-py3-none-any.whl.metadata (3.0 kB)\n",
      "Requirement already satisfied: blinker>=1.6.2 in /opt/conda/lib/python3.11/site-packages (from Flask) (1.6.3)\n",
      "Requirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.11/site-packages (from Jinja2>=3.1.2->Flask) (2.1.3)\n",
      "Downloading flask-3.0.0-py3-none-any.whl (99 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m99.7/99.7 kB\u001b[0m \u001b[31m3.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading click-8.1.7-py3-none-any.whl (97 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m97.9/97.9 kB\u001b[0m \u001b[31m6.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hDownloading werkzeug-3.0.1-py3-none-any.whl (226 kB)\n",
      "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m226.7/226.7 kB\u001b[0m \u001b[31m7.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hInstalling collected packages: Werkzeug, itsdangerous, click, Flask\n",
      "Successfully installed Flask-3.0.0 Werkzeug-3.0.1 click-8.1.7 itsdangerous-2.1.2\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "pip install Flask"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "adc99814-0460-4b44-bcca-60287273d5c0",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (4076106235.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;36m  Cell \u001b[0;32mIn[4], line 1\u001b[0;36m\u001b[0m\n\u001b[0;31m    python ai_translator/app.py\u001b[0m\n\u001b[0m           ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "python ai_translator/app.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d4e068d6-08e0-4bd8-a10f-08e856e63d38",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
